<%--
  Created by IntelliJ IDEA.
  User: 栋
  Date: 2022/12/3
  Time: 16:37
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <%@include file="/pages/base/base.jsp"%>
    <script>
        function confirmOrder(order_id){
            var x=order_id.cells
            var arrival=x[8].innerText;
            var order_id=x[0].innerText;
            if(arrival=="是"){
                alert("该订单已确认收货")
                return;
            }
            r=confirm("是否确定收货");
            if(r==true){
                window.location.href="userServlet?action=confirmOrder&order_id="+order_id;
            }
        }
    </script>
</head>
<body>
<div class="container">
    <%@include file="/pages/base/head.jsp"%>
    <%@include file="/pages/base/topnav_afterLogin.jsp"%>
    <div class="errorMsg">
        ${requestScope.msg}
    </div>
    <c:if test="${sessionScope.orders!=null}">
        <table id="personalItems_tb">
            <tr>
                <th>订单编号</th>
                <th>商品编号</th>
                <th>商品名称</th>
                <th>交易方式</th>
                <th>购买数量</th>
                <th>总价</th>
                <th>购买日期</th>
                <th>购买时间</th>
                <th>是否到货</th>
                <th>确认收货</th>
            </tr>
            <c:forEach items="${sessionScope.orders}" var="order">
                <tr id="${order.order_id}">
                    <td>${order.order_id}</td>
                    <td>${order.item_id}</td>
                    <td>${order.item_name}</td>
                    <td>${order.address}</td>
                    <td>${order.buy_count}</td>
                    <td>${order.total_price}</td>
                    <td>${order.buy_date}</td>
                    <td>${order.buy_time}</td>
                    <td>${order.arrival}</td>
                    <td id="confirm"><a onclick="confirmOrder(${order.order_id})" href="javascript:void(0);">确认</a></td>
                </tr>
            </c:forEach>
        </table>

    </c:if>

</div>
</body>
</html>
